{extend name="$base" /}
{block name="resources"}
<style>
.modal-tab tr:first-child{border-bottom:1px solid #ccc;}
.modal-tab td:first-child{line-height: 50px;text-align:right;width: 25%;}
input[type="text"], input[type="password"], input.text, input.password{margin-top:18px;}
.back-color{
	color: #ffffff;
    padding: 3px 5px;
    border-radius: 15px;
    font-size: 12px;
    margin-left: 10px;
}
.color_1{background: darkcyan;}
.color_2{background: goldenrod;}
.color_3{background: darkcyan;}
.color_4{background: green;}
.color_5{background: red;}
.table-div span.right{
	 margin-left: 10px;
}
.btn_bind{
	background: #00A0DE;
    border-radius: 11px;
    color: #ffffff;
    padding: 3px 8px;
    font-size: 12px;
    margin-right: 5px;
}
.btn_bind:hover{
	color: #ffffff;
}
.authorization-process{
	width: 1000px;
	margin: 100px auto;
}
.authorization-head{
	height: 35px;
	font-weight: 600;
	line-height: 35px;
	text-align: center;
}
.authorization-body{
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
}
.authorization-body li{
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 435px;
	margin-bottom: 20px;
}
.authorization-body .head{
	width: 35px;
	height: 35px;
	line-height: 35px;
	text-align: center;
	border-radius: 50%;
	background-color: #ffa03f;
	color: #fff;
	margin-bottom: 30px;
}
.authorization-body .desc{
	margin-bottom: 20px;
	font-size: 18px;
	color: #333;
}
.mod-table{
	padding: 0 10px
}

</style>
{/block}
{block name="main"}
<div class="space-10"></div>
<div class="mod-table">
	<div class="table-div">
		<table>
			<tbody>
			<tr>
				<td>
					授权状态：{eq name="$devolutioninfo['devolution_status']" value="1"}
					<span class="back-color color_4">已授权</span>{else/}<span class="back-color color_5">未授权</span><a href="http://www.niushop.com.cn/authorization.html" target="_blank" class="btn_bind">去授权</a>{/eq}
				</td>
			</tr>
			<tr>
				<td>
					授权版本：
					<span>{$devolutioninfo.devolution_version}</span>
				</td>
			</tr>
			<tr>
				<td>
					授权域名：
					<span>{$devolutioninfo.devolution_url}</span>
				</td>
			</tr>
			<tr>
				<td>
					服务时间：
					<span>{$expire_date}</span>
				</td>
			</tr>
			<tr>
				<td>
					当前版本：<span class="back-color color_2">{$niu_version}</span>
				</td>
			</tr>
			<tr>
				<td>
					最新版本：<span class="back-color color_1">V{$latestVersion.data.latest_version}</span>
				</td>
			</tr>
			</tbody>
		</table>
	</div>
</div>
{if condition="$result['code'] neq 0"}
<div class="authorization-process">
	<h2 class="authorization-head">授权过程</h2>
	<ul class="authorization-body">
		<li>
			<div class="head">1</div>
			<div class="desc">打开niushop官网（https://www.niushop.com.cn/）</div>
			<img src="ADMIN_IMG/authorization_one.png" alt="">
		</li>
		<li>
			<div class="head">2</div>
			<div class="desc">点击授权选择B2C单商户授权或B2B2C多商户授权</div>
			<img src="ADMIN_IMG/authorization_two.png" alt="">
		</li>
		<li>
			<div class="head">3</div>
			<div class="desc">点击购买</div>
			<img src="ADMIN_IMG/authorization_three.png" alt="">
		</li>
	</ul>
</div>
{/if}
<div class="modal fade hide" id="bind_user" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:400px;left:56%">

	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h3>云平台绑定</h3>
			</div>
			<div class="modal-body">
				<div class="modal-infp-style" style="height:165px;width:320px;margin:auto;">
					<table class="modal-tab" style="width: 100%;">
						<tr>
							<td colspan="2" style="text-align:left">输入Niushop官方授权码完成绑定
							<a style="float:right;color:#00C0FF;" href="http://www.niushop.com.cn/authorization.html" target="_blank" >授权</a>
							</td>
						</tr>
						<tr>
							<td>授权码：</td>
							<td>
								<input id="authorization_code" type="text" class="input-common"/>
							</td>
						</tr>
					</table>
				</div>
			</div>

			<div class="modal-footer">
				<input type="hidden" id="modify_username_hidden" />
				<button class="btn-common" onclick="binding()" id="butSubmit">绑定</button>
			</div>
		</div>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
function bind(){
	$("#bind_user").modal("show");
}

function binding(){
	var authorization_code = $("#authorization_code").val();
	if(authorization_code.length == 0){
		showTip("请输入授权码","warning");
		return;
	}
	$.ajax({
		type:'post',
		url : "{:__URL('ADMIN_MAIN/Upgrade/onlineUpdate')}",
		data:{
			'authorization_code':authorization_code,
		},
		success:function(data){
			if(data['code']==0){
				showMessage('success',data['message']);
				$("#bind_user").modal("hide");
				window.location.reload();
			}else{
				showMessage('error',data['message']);
			}
		}
	})
}
</script>
{/block}